package com.itheima.collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Demo03 {

    public static void main(String[] args) {
        Collection<String> list= new ArrayList<>();
        list.add("test");
        list.add("test");
        list.add("张三");
        list.add("李四");
        list.add("test");
        Iterator<String> iterator = list.iterator();
        //ConcurrentModificationException 在遍历的过程中不能对集合进行操作
        while (iterator.hasNext()){
            String s = iterator.next();
            if(s.equals("test")){
              iterator.remove();
            }
        }
        System.out.println(list);

    }
}
